/**
 * Created by chaoCheng on 2017/1/13.
 */
angular.module('playFile', [])//模块名，注入到admin 主模块中
    .config(function DetailRoutes($stateProvider) {
        $stateProvider
            .state('detail', {//路由名称
                parent: 'admin',
                url: '/detail?{planId:string}',//url以及参数定义
                params: {
                    page: { value: 1, squash: true },//初始化url中的参数，不需要可以不写
                    size: { value: 2, squash: true }
                },
                views: {
                    'main@admin': {
                        templateUrl: 'admin/plan/filelist.html',//html地址
                        controller: 'DetailController as vm',//控制器和他的别名
                        resolve: {
                            fileandgroups: function(Detail, $stateParams) {
                                return Detail.searchfileandgroup({
                                    planId : $stateParams.planId,
                                })
                            }
                        }
                    }
                }
            })
           /*.state('groupSearch',{
                url: '/groupSearch?{planId:string}',
                params: {
                    page: { value: 1, squash: true },//初始化url中的参数，不需要可以不写
                    size: { value: 10, squash: true }
                },
               controller: 'GroupController as vm',//控制器和他的别名
               templateUrl: 'admin/plan/grouplist.html',
               resolve: {
                   groupList: function(Group, $stateParams) {//从后台预加载的数据,Demo-注入的service
                       return Group.searchGroup({
                           groupName : $stateParams.groupName,
                           pageInfo: {
                               pageSize: $stateParams.size,
                               pageNumber: $stateParams.page
                           }
                       })
                   }
               }

            })*/
            .state('fileAdd',{
                url: '/fileAdd?{planId:string}',
                controller: 'FileAddController as vm',//控制器和他的别名
                templateUrl: 'admin/plan/fileAdd.html'
            })
            .state('groupSearch',{
                url: '/groupSearch?{planId:string}',
                controller: 'GroupController as vm',//控制器和他的别名
                templateUrl: 'admin/plan/grouplist.html'
            })
            .state('filepreview',{
                url: '/filepreview?{filePath:string}&{planId:string}',
                controller: 'FileAddController as vm',//控制器和他的别名
                templateUrl: 'admin/plan/filepreview.html'
            })

    })
    .service('Detail', DetailModel)//声明
    .service('Group',GroupModel)
    .controller('DetailController', DetailController)
    .controller('GroupController', GroupController)
    .controller('FileAddController', FileAddController)
    .controller('GroupAddController',GroupAddController)




    .controller('PlanFileInstanceCtrl', function ($scope, $uibModalInstance) {
        $scope.ok = function () {
            $uibModalInstance.close('ok');
        };

        $scope.cancel = function () {
            $uibModalInstance.close('cancel');
            //$uibModalInstance.dismiss('cancel');
        };

    })
.controller('GroupInstanceCtrl', function ($scope, $uibModalInstance) {
    $scope.ok = function () {
        $uibModalInstance.close('ok');
    };

    $scope.cancel = function () {
        $uibModalInstance.close('cancel');
        //$uibModalInstance.dismiss('cancel');
    };

});


